import React from 'react';
import { Switch, withRouter, Route, Redirect } from 'react-router-dom';
import Loadable from 'react-loadable';
const routesArray = [
    {
        path: '/',
        exact: true,
        main: Loadable({
            loader: () => import(/* webpackChunkName: "A" */ 'modules/a/a'),
            loading: () => <div>loading ...</div>
        })
    }
];

const Routes = withRouter(({ location }) => (
    <Switch>
        {routesArray.map((route, index) => (
            <Route key={index} path={route.path} exact={route.exact} component={route.main} />
        ))}

        <Redirect from="/" to="/" />
    </Switch>
));

export default Routes;
